package com.hw01.controller;

import com.hw01.controller.vo.ResultVO;
import com.hw01.service.UserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AuthController
 * @Description TODO
 * @Author Kx
 * @Date 2025/5/14 14:52
 * @Version 1.0
 */
@RestController
public class AuthController extends BaseController{

    // 业务层对象
    private final UserService service;

    public AuthController(UserService service) {
        this.service = service;
    }

    /**
     * @author: kx
     * @date: 2025/5/13 19:55
     * @param account : 账号
     * @param password : 密码
     * @return com.controller.vo.ResultVO<com.entity.User>
     * @description: 登录验证
     */
    @PostMapping("/login")
    public ResultVO<String> login(@RequestParam("account") String account, @RequestParam("password") String password) {
        // 获取令牌信息
        String user = service.login(account, password);
        return success(user);
    }
}
